﻿@using zichan.BLL.StatisticsModel
@using zichan.Common;
@model List<AssetStatiticsModel>
@{
    ViewBag.Title = "资产统计";
}

@section Pagetitle{
    @AdminCommon.PageTitle("资产统计", "")
}

<div class="portlet">
    <div class="portlet-title">
        <div class="caption ">
            <i class="fa fa-table"></i>资产统计
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-container">
            <div class="dataTables_wrapper dataTables_extended_wrapper no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-group-actions pull-left">
                            @using (Html.BeginForm("AssetIndex", "Statistics", FormMethod.Get, new { @class = "form-inline" }))
                            {
                                
                                <div class="form-group">
                                    @Html.DropDownList("assetClassId", (SelectList)ViewBag.assetClassIds, "全部资产分类", new { @class = "form-control input-small input-sm" })
                                </div>
                                <div class="form-group">
                                    @Html.DropDownList("serverPurposeId", (SelectList)ViewBag.serverPurposeIds, "用途", new { @class = "form-control input-small input-sm" })
                                </div>
                                <div class="form-group">
                                    @Html.DropDownList("companyId", (SelectList)ViewBag.companyIds, "全部公司", new { @class = "form-control input-small input-sm" })
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" placeholder="采购时间" name="sdt" id="sdt" value="@ViewBag.sdt" class="form-control input-small input-sm dateSdt" />
                                        <span class="input-group-addon dateSdt">
                                            <i class="fa fa-calendar bigger-110 "></i>
                                        </span>
                                    </div>
                                    至
                                    <div class="input-group">
                                        <input type="text" placeholder="采购时间" name="edt" id="edt" value="@ViewBag.edt" class="form-control input-small input-sm  dateEdt" />
                                        <span class="input-group-addon dateEdt">
                                            <i class="fa fa-calendar bigger-110"></i>
                                        </span>
                                    </div>
                                </div>
                                <button class="btn btn-sm yellow table-group-action-submit"><i class="fa fa-check"></i> 搜索</button>
                            }
                        </div>
                    </div>
                </div>
                <div class="form-group"><h5>资产分类总数:<span style="color:red;">@Model.Select(o=>o.Id).Count()</span></h5></div>
                <div class="table-scrollable">
                    <table class="table  table-hover">
                        <thead>
                            <tr class="heading">
                                <th>资产分类</th>
                                <th>库存</th>
                                <th>使用中</th>
                                <th>报废</th>
                                <th>总数</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (AssetStatiticsModel r in Model)
                            {
                                <tr>
                                    <td>@r.Name</td>
                                    <td ><a style="@(r.RepertoryNumber==0?"color:red":"")" href="/RepertoryManage/Index?statu=1&assetClassId=@r.Id&serverPurposeId=@ViewBag.serverPurposeId&companyId=@ViewBag.companyId&sdt=@ViewBag.sdt&edt=@ViewBag.edt">@r.RepertoryNumber</a></td>
                                    <td><a href="/RepertoryManage/Index?statu=2&assetClassId=@r.Id&serverPurposeId=@ViewBag.serverPurposeId&companyId=@ViewBag.companyId&sdt=@ViewBag.sdt&edt=@ViewBag.edt">@r.InuseNumber</a></td>
                                    <td><a href="/RepertoryManage/Index?statu=3&assetClassId=@r.Id&serverPurposeId=@ViewBag.serverPurposeId&companyId=@ViewBag.companyId&sdt=@ViewBag.sdt&edt=@ViewBag.edt">@r.ScrapNumber</a></td>
                                    <td><a href="/RepertoryManage/Index?assetClassId=@r.Id&serverPurposeId=@ViewBag.serverPurposeId&companyId=@ViewBag.companyId&sdt=@ViewBag.sdt&edt=@ViewBag.edt">@r.TotalNumber</a></td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                @if (PowerHelp.Check("Excel", "AssetStatisticsExc"))
                {
                    <div class="row">
                        <div class="col-md-12">
                            <a href="@Url.Action("AssetStatisticsExc", "Excel", new {assetClassId=ViewBag.assetClassId,serverPurposeId=ViewBag.serverPurposeId,companyId=ViewBag.companyId,sdt=ViewBag.sdt, edt=ViewBag.edt})" class="btn default green">
                                <i class="fa fa-table"></i>
                                <span class="hidden-480">Excel导出报表</span>
                            </a>
                        </div>
                    </div>
                }
            </div>

        </div>
    </div>
</div>
@section footer{
    <script src="/assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var formatDateTime = function (date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return y + '/' + m + '/' + d;
        };
        $('.dateSdt').datetimepicker({
            language: 'zh-CN',
            weekStart: 1,
            todayBtn: 0,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            minView: 'month',　　　　//日期时间选择器所能够提供的最精确的时间选择视图。
            format: 'yyyy/m/d'
        }).on('changeDate', function (ev) {
            $("#sdt").val(formatDateTime(new Date(ev.date.valueOf() - 28800000)));
        });
        $('.dateEdt').datetimepicker({
            //language: 'zh-CN',
            weekStart: 1,
            todayBtn: 0,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            minView: 'month',　　　　//日期时间选择器所能够提供的最精确的时间选择视图。
            format: 'yyyy/m/d'
        }).on('changeDate', function (ev) {
            $("#edt").val(formatDateTime(new Date(ev.date.valueOf() - 28800000)));
        });
      
    </script>
}
